// 首页
// https://wap.paixiaoxian.com/web_adapter/adapter.html

// 登录
// https://wap.paixiaoxian.com/web_adapter/adapter.html

// 接单
// https://home.paixiaoxian.com/index.php/User/Task/getorderlist/



function setAndroidToken() {
    let token = Android.getMap("token")
    if (!token) {
        return
    }

    token = token.split(",")
    localStorage.setItem("userid", token[0])
    localStorage.setItem("username", token[1])
}
setAndroidToken()

// 获取tokeN
function getAndroidToken() {
    let username = localStorage.getItem("username").replace(/^"|"$/g, '');
    let userid = localStorage.getItem("userid").replace(/^"|"$/g, '');
    let token = userid + "," + username
    return token
}
getAndroidToken()


// 接单
function getParameterHandler() {
    let token = parameter.getMap("token")
    if (!token) {
        return
    }
    token = token.split(",")
    let headers = {}
    let body = {
        "username": token[1],
        "userid": token[0],
        "status": "2"
    }
    let strUrl = ``
    let url = parameter.getMap("url") + strUrl
    return {
        mediaType: "form",
        requestType: "POST",
        url: url,
        headers: JSON.stringify(headers),
        body: JSON.stringify(body)
    }
}
getParameterHandler()



function getResponse() {
    let res = response.getMap("res")
    res = JSON.parse(res)

    let code = "500"
    let message = res["msg"]

    if (res["status"] == 0 && res["data"].length > 0) {
        code = "200"
    } else if (res["status"] == 0 && res["data"].length <= 0) {
        code = "500"
    } else {
        code = "300"
    }

    return {
        code: code,
        message: message,
        dataKey: "",
        dataValue: ""
    }
}
getResponse()